home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / What's New? / Sample Code / Graphics 2D / Out of This GWorld / events.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  2.4 KB  |  97 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        events.c
  3.  
  4.     Contains:    
  5.  
  6.     Written by: EL    
  7.  
  8.     Copyright:    Copyright © 1991-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 08/2000        JM                Carbonized, non-Carbon code is commented out
  20.                                             for demonstration purposes.
  21.                 7/16/1999    KG                Updated for Metrowerks Codewarror Pro 2.1
  22.                 
  23.  
  24. */
  25. #include "out.h"
  26.  
  27. void pollEvents()
  28. {
  29.     EventRecord anEvent;
  30.     WindowPtr   theWindow;
  31.     short       clickArea;
  32.     Rect        screenRect;
  33.     long        sleep;
  34.     Rect        tempRect1;
  35.     
  36.     sleep = 0;
  37.     
  38.     for (;;)
  39.     {
  40.         if (gCurrentMove == START)
  41.             animateCTable();
  42.         
  43.         if (WaitNextEvent (everyEvent, &anEvent, sleep, (RgnHandle) nil))
  44.         {
  45.             if (anEvent.what == mouseDown)
  46.             {
  47.                 clickArea = FindWindow( anEvent.where, &theWindow );
  48.                 
  49.                 if (clickArea == inDrag)
  50.                 {
  51.                     //screenRect = (**GetGrayRgn ()).rgnBBox;
  52.                     GetRegionBounds(GetGrayRgn(), &screenRect);
  53.                     DragWindow(theWindow, anEvent.where, &screenRect );
  54.                 }
  55.                 else if (clickArea == inGoAway)
  56.                 {
  57.                     if (TrackGoAway( theWindow , anEvent.where ))
  58.                         cleanUp();
  59.                 }
  60.                 
  61.                 else if (clickArea == inMenuBar)
  62.                 {
  63.                     adjustMenus();
  64.                     handleMenu( MenuSelect( anEvent.where ) );
  65.                 }
  66.                 else if (clickArea == inContent)
  67.                 {
  68.                     if (theWindow != FrontWindow())
  69.                         SelectWindow( gWindow );
  70.                 }
  71.             }
  72.             else if (anEvent.what == updateEvt)
  73.             {
  74.                 theWindow = (WindowPtr)anEvent.message;
  75.                 
  76.                 BeginUpdate( theWindow );
  77.                 //SetPort( theWindow );
  78.                 SetPortWindowPort( theWindow );
  79.                 drawImage();
  80.                 EndUpdate( theWindow );
  81.             }
  82.             else if (anEvent.what ==  keyDown || anEvent.what == autoKey)
  83.             {
  84.                 if ((anEvent.modifiers & cmdKey) != 0)
  85.                 {
  86.                     adjustMenus();
  87.                     handleMenu( MenuKey( (char)(anEvent.message & charCodeMask) ) );
  88.                 }
  89.             }
  90.             else if (anEvent.what == activateEvt)
  91.             {
  92.                 //InvalRect( &gWindow->portRect );
  93.                 InvalWindowRect( gWindow, &tempRect1);
  94.             }
  95.         }
  96.     }
  97. }